package com.atguigu.cloud.config;

import com.mysql.cj.jdbc.MysqlDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfiguration {

    @Bean
    public DataSource dataSource() {
        MysqlDataSource mysqlDataSource = new MysqlDataSource();
        /*
        *  Public Key Retrieval is not allowed 异常MySQL8身份验证方式改变导致解决方案：
        *  在连接数据库时，添加 allowPublicKeyRetrieval=true 参数，即可解决该异常。
        * */
        mysqlDataSource.setUrl("jdbc:mysql://192.168.1.121:3306/camunda?serverTimeZone=UTC&useSSL=false&allowPublicKeyRetrieval=true");
        mysqlDataSource.setUser("root");
        mysqlDataSource.setPassword("abc123");
        return mysqlDataSource;
    }

}
